﻿<DockPanel x:Class="DevControlLibrary.UI.SQLControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="311" d:DesignWidth="439" 
             xmlns:avalonedit="clr-namespace:ICSharpCode.AvalonEdit;assembly=ICSharpCode.AvalonEdit"
             >
    
    <DockPanel.Resources>
        <RoutedUICommand x:Key="format" Text="格式刷"/>
      
        <RoutedUICommand x:Key="position" Text="定位"/>
        <RoutedUICommand x:Key="query" Text="查找"/>
        <RoutedUICommand x:Key="zhushi" Text="注释"/>
        <RoutedUICommand x:Key="nozhushi" Text="取消注释" />
        <RoutedUICommand x:Key="Splice" Text="C#拼接"/>
        <ContextMenu x:Key="SQLMenu">
            <MenuItem Header="复制" Command="Copy">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/Tool/copy-16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="粘贴" Command="Paste">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/Tool/paste-16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <Separator/>
            <MenuItem Header="撤销" Command="Undo">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/Tool/undo-16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="重做" Command="Redo" >
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/Tool/redo-16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="注释" Command="{StaticResource zhushi}">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/IndentIncrease_16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="取消注释" Command="{StaticResource nozhushi}">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/IndentDecrease_16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <Separator/>
            <MenuItem Header="格式刷" Command="{StaticResource format}" InputGestureText="Ctrl+R" ToolTip="将帮您将很长的语句给分解开">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/FormatPainter.gif" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Header="C#" Command="{StaticResource Splice}" ToolTip="转换成c#拼接模式"></MenuItem>
            <Separator/>
          
            <MenuItem Header="定位" Command="{StaticResource position}" InputGestureText="Ctrl+T" ToolTip="当您选中表名时,使用此功能将快速定位到左侧的树中">
            </MenuItem>
            <MenuItem Header="智能提示" Command="{StaticResource query}" InputGestureText="Ctrl+Q">
                <MenuItem.Icon>
                    <Image Source="/QueryResource;component/Images/Tool/Find_16x16.png" Height="16" Width="16"/>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </DockPanel.Resources>
    <DockPanel.InputBindings>
        <KeyBinding Modifiers="Ctrl" Key="R" Command="{StaticResource format}"/>
      
        <KeyBinding Modifiers="Ctrl" Key="T" Command="{StaticResource position}"/>
        <KeyBinding Modifiers="Ctrl" Key="Q" Command="{StaticResource query}" />
        <KeyBinding Modifiers="Ctrl" Key="K" Command="{StaticResource zhushi}"/>
        <KeyBinding Modifiers="Ctrl" Key="L" Command="{StaticResource nozhushi}" />
    </DockPanel.InputBindings>
    <DockPanel.CommandBindings>
        <CommandBinding Command="{StaticResource format}"   
                        Executed="Format_CommandBinding_Executed"
                        CanExecute="Format_CommandBinding_CanExecute"/>
        <CommandBinding Command="{StaticResource position}"   
                        Executed="Position_CommandBinding_Executed"
                        CanExecute="Position_CommandBinding_CanExecute"/>
        <CommandBinding Command="{StaticResource query}"   
                        Executed="Query_CommandBinding_Executed"/>
        <CommandBinding Command="{StaticResource zhushi}"
                        Executed="zhushi_CommandBinding_Executed"/>
        <CommandBinding Command="{StaticResource nozhushi}"
                        Executed="NoZhushi_CommandBinding_Excuted"/>
        <CommandBinding Command="{StaticResource Splice}"
                        Executed="Splice_CommandBinding_Executed"
                        CanExecute="Splice_CommandBinding_CanExecute"/>
    </DockPanel.CommandBindings>
   
    <avalonedit:TextEditor 
            Name="textEditor1"    
            FontSize="14"
            ShowLineNumbers="True"
            KeyDown="textEditor1_KeyDown"
            KeyUp="textEditor1_KeyUp"
            ContextMenu="{StaticResource SQLMenu}">
    </avalonedit:TextEditor>
</DockPanel>
